import { createRouter, createWebHistory } from 'vue-router'
// 导入单文件组件
// import HomeView from '../views/HomeView.vue'
// import SearchView from '@/views/SearchView.vue'
// import MyView from '@/views/MyView.vue'
// import NotFind from '@/views/NotFind.vue'

// 创建路由
const router = createRouter({
  // 配置路由模式
  history: createWebHistory(import.meta.env.BASE_URL),
  // 配置路由表
  routes: [
    {
      // 路径
      path: '/',
      // 路由别名
      name: 'home',
      // 路由组件
      component: () => import('@/views/HomeView.vue'),
    },
    // 首页
    {
      path: '/home',
      component: () => import('@/views/HomeView.vue'),
    },
    // 搜索
    {
      path: '/search/:words?',
      name: 'search',
      component: () => import('@/views/SearchView.vue'),
    },
    // 我的
    {
      path: '/my',
      name: 'MyView',
      component: () => import('@/views/MyView.vue'),
    },
    {
      //
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.

      // 路由懒加载
      component: () => import('../views/AboutView.vue'),
    },
    // 404页面
    {
      path: '/:catchAll(.*)',
      component: () => import('@/views/NotFind.vue'),
    },
  ],
})

export default router
